package cc.verywell.pureblock.net;

/**
* 
* 一个时间管理控件;
	 * 如果您有更好的管理方案，可以像这样重载本类;
	 * <p> <b>Usage Example:</b> </p>
	 * <pre>
	 * AioProvider.generator = new TimelogProvider(){
	 *  public Timelog getTimelog(NormalSession nss) {
	 * 	 //TODO your code to return Timelog;
	 * 	 return myTimelog;
	 * 	}
	 * };</pre>
	 * 
* 
* Copyright © 2019 TanYaqiu. All rights reserved.
* @author TanYaqiu 
* @address flat 601
* @date 2019年3月19日 下午8:23:17
*/
public interface Timelog {
	public void read(int size);
	public void worte(int size);
	public long getLastWriteTime();
	public long getLastReadTime();
	
	/**
	 * 自编接口,用来实现Timelog
	 */
	static public interface TimelogGenerator{
		public Timelog getTimelog(NormalSession nss);
	}
	
	/**
	 * <p>DefaultTimelog 最基本的Timelog 实现;</p>
	 * @author TanYaqiu 
	 * Copyright © 2019 TanYaqiu. All rights reserved.
	 */
	static public class BasicTimelog implements Timelog{
		public long lastReadTime = System.currentTimeMillis(); //必要,timeout要用
		public long lastWriteTime = lastReadTime; //必要,timeout要用
		@Override
		public void read(int size) {
			lastReadTime = System.currentTimeMillis();
		}
		@Override
		public void worte(int size) {
			lastWriteTime = System.currentTimeMillis();
		}
		@Override
		public long getLastWriteTime() {
			return lastWriteTime;
		}
		@Override
		public long getLastReadTime() {
			return lastReadTime;
		}
	}

	
	
	
}
